#include "TcpServer.h"
#include "TcpConnection.h"


TcpServer::TcpServer(const std::string& ip,unsigned short port)
:_acceptor(ip,port),
_loop(_acceptor)
{
    _acceptor.ready();
}
TcpServer::~TcpServer()
{
    
}
void TcpServer::start()
{
    _loop.loop();
}
void TcpServer::stop()
{
    _loop.unLoop();
}
void TcpServer::setAllCallback(TcpConnectionCallback&& newConnectionCallback,
                                TcpConnectionCallback&& messageCallback,
                                TcpConnectionCallback&& closeCallback)
{
    _loop.setNewConnectionCallback(std::move(newConnectionCallback));
    _loop.setMessageCallback(std::move(messageCallback));
    _loop.setCloseCallback(std::move(closeCallback));
}